﻿@model ResetPasswordIM
@{
    ViewBag.Title = "重设密码";
}

<div class="container">
    @if (ViewData["Error"] != null)
    {
        <div class="alert alert-danger">
            <p>@ViewData["Error"]</p>
        </div>
    }
    else
    {
        using (Ajax.BeginForm("ResetPassword", null, new AjaxOptions
        {

            HttpMethod = "POST",
            OnBegin = "onBeginSave",
            OnComplete = "onCompleteSave",
            OnSuccess = "updateSuccess"

        }, new { role = "form", @class = "form-horizontal" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)
            @Html.HiddenFor(m=>m.UserName)

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">修改密码</h3>
                </div>
                <div class="panel-body">                   

                    <div class="form-group">
                        @Html.LabelFor(u => u.Password, new { @class = "col-xs-4 control-label" })
                        <div class="col-xs-8">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = Labels.Password })
                            @Html.ValidationMessageFor(model => model.Password)
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(u => u.ConfirmPassword, new { @class = "col-xs-4 control-label" })
                        <div class="col-xs-8">
                            @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control", placeholder = Labels.ConfirmPassword })
                            @Html.ValidationMessageFor(model => model.ConfirmPassword)
                        </div>
                    </div>

                </div>
                <div class="panel-footer text-center">

                    <button class="btn btn-primary" type="submit" id="btnSave"><i class="fa fa-save fa-fw"></i>保存</button>
                    <a href="@Url.Action("Index","Home")" class="btn btn-default">返回首页</a>
                </div>
            </div>

        }
    }

</div>


@section Footer {
    @Scripts.Render("~/bundles/jqueryvalWithBootstrap")
    <script>

    function onBeginSave() {
        $("#btnSave i").removeClass("fa-save").addClass("fa-spinner fa-spin");
    }
    function onCompleteSave() {
        $("#btnSave i").removeClass("fa-spinner fa-spin").addClass("fa-save");
    }

    function updateSuccess(data) {
        var title = '@ViewBag.Title';
        Common.ShowBox(data.Status, data.Message, title);
    }

        $(function () {

        })
    </script>
}